How to Plot Spectral Data with Prospect, Specutils and the Astro Data Lab Spectrum Service

Table of Contents

Goals

Obtain SDSS spectra using the Astro Data Lab spectrum service, convert data to specutils objects as needed, and use Prospect to display the data.

Summary

Prospect is an interactive spectrum visualization service that is being actively used by the DESI project for visual inspection of commissioning and survey validation spectra right now. Rather than just a simple flux versus wavelength plot, the interactive spectrum display provides pan, zoom, known spectral lines, targeting and other catalog information, metadata, etc. The Bokeh library handles the low-level interactivity.

We can leverage the generic spectrum container objects provided by specutils to allow Prospect to plot data from other surveys. In this example, we are using SDSS DR16.

In the future we will extend this functionality to additional instruments. For example, we are excited by the possibility of using Prospect and the Astro Data Lab spectrum service for Gemini spectra. And, of course, once DESI data become public, both the spectrum service and this tool will be ready.

Disclaimer & Attribution

If you use this notebook for your published science, please acknowledge the following:

Imports & Setup

This cell performs all necessary imports for this notebook.

Authentication

Much of the functionality of spectrum services can be accessed without explicitly logging into Astro Data Lab (the service then uses an anonymous login). But some capabilities, for instance saving the results of your queries to your virtual storage space, require a login (i.e. you will need a registered user account).

If you need to log in to Astro Data Lab, uncomment the ac.login() command and respond according to the prompts. If you have previously logged into Astro Data Lab, this cell will simply print your active user name.

SDSS/eBOSS spPlate file

SDSS spectra are stored per-plate in spPlate files. These contain 640 spectra for the original SDSS spectrograph or 1000 spectra for the BOSS/eBOSS spectrograph. All spectra in an individual spPlate file have a common wavelength solution, so a single spPlate file can be represented by a Spectrum1D object. The Prospect visualization package can then take this Spectrum1D object as input data.

Find Plate 2955 in the Spectrum Service

In the cells below, we will find spectra corresponding to SDSS plate 2955, but using the spectrum service instead of reading the spectra from a file. This starts by finding the coordinates of the plate center.

Spectrum Identifiers

SDSS plates are circular, so we'll do a cone search around the plate center found above. This gets us the spectrum identifiers we need to retrieve the spectra themselves.

Spectrum Service: Flux versus Wavelength

Now we fetch the spectra. The option align=True directes the service to return all spectra as a single Spectrum1D object with a common wavelength axis for all spectra. Since all spectra on a single SDSS plate have a common wavelength axis anyway, this is a simple operation.

Redshift and other Metadata

The Prospect viewer requires certain spectral metadata that are normally provided with SDSS spectra--i.e., these metadata are stored alongside the flux versus wavelength data. There are two categories of metadata:

  1. Redshift catalog: this contains the redshift (how far away it is) and classification (what type of object it is) for each spectrum, as identified by the SDSS pipeline.
  2. Target catalog: this contains the information needed for taking a spectrum of the object in the first place. This includes information about the object as identified in SDSS imaging (RA, Dec, optical magnitude), as well as the rationale for taking a spectrum of the object.

In the cells below, we will extract the necessary metadata from the specobj and photoplate tables and reformat them slightly to match the appearance of these data as they would be extracted from SDSS files.

Redshift Catalog

This query extracts the redshift and classification information from the specobj table.

Target Catalog

This query extracts photometric targeting information from the photoplate table. The data obtained needs to be reformatted to match the "plugmap" metadata that is stored with SDSS spectrum files, including spPlate files.

Launch the Visualization

Once all the spectral data are assembled, the visualization is launched with a single plotspectra() function in the cell below. The primary input is the Spectrum1D object created above. Prospect expects a certain scaling on the input flux, so sdss.new_flux_unit() handles that (this changes the numerical scale factor on the flux unit, not the flux unit itself). Other inputs:

Once the cell is run, it will take several seconds for the data to load and render. Then you will be able to pan and zoom on the primary flux versus wavelength display, page through different spectra, show known emission or absorption lines, etc. More details are below the display.

Visualization Interface Details

SDSS Spectra and Redshifts from Files

For reference, and to compare timing, below is how one would fetch spectra and redshift metadata from file-based storage. First, obtain the path to the files in the Astro Data Lab file service.

Next, read the spPlate file. This automatically loads the targeting metadata.

Read the spZbest file, which contains the redshift catalog.

Launch the visualization. Reading from files produces slightly different scaling on the flux values, but otherwise the options are the same as the example above.

References & Resources